package com.hui.noExchange;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class HelloProducer {
        public static final Logger logger = LoggerFactory.getLogger(HelloProducer.class);

        @Autowired
        private AmqpTemplate rabbitTemplate;
        public void send(){
            String message = "hello "+new Date();
            logger.info("message:"+message);
            rabbitTemplate.convertAndSend("hello",message);
            logger.info("队列发送成功");
        }
}
